home *** CD-ROM | disk | FTP | other *** search
- package com.extensibility.app;
-
- import com.extensibility.plugin.api.PrintPreferences;
- import com.extensibility.util.Debug;
- import com.extensibility.xml.URI;
- import java.awt.Component;
- import java.awt.Font;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.FileNotFoundException;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.io.OutputStream;
- import java.util.Enumeration;
- import java.util.Hashtable;
- import java.util.Properties;
- import java.util.Vector;
-
- public class ApplicationPreferences extends Properties {
- public static final String PREF_FILENAME = "_Preferences";
- public static final String RECENT = "RECENT.";
- public static final String RECENT_1 = "RECENT.1";
- public static final String RECENT_2 = "RECENT.2";
- public static final String RECENT_3 = "RECENT.3";
- public static final String RECENT_4 = "RECENT.4";
- public static final String RECENT_5 = "RECENT.5";
- public static final String PLATFORM = "os.name";
- public static final String MACOS = "Mac";
- public static final String USER_NAME_CODE = "ESB";
- public static final String ORGANIZATION_CODE = "KKB";
- public static final String EMAIL_CODE = "EMC";
- public static final String PHONE_CODE = "PHC";
- public static final String SN_CODE = "CAB";
- public static final String LAUNCHES_LEFT = "EGB";
- public static final String REG_SENT = "RGS";
- public static final String OEM_PARTNER_KEY = "OEM";
- public static final String TOOLBAR_VIEW = "TOOLBAR.VIEW";
- public static final String ONLINE_HELP = "ONLINE.HELP";
- public static final String EXTERNAL_HELP_BROWSER = "EXTERNAL.HELP.BROWSER";
- public static final String SHOW_WELCOME = "SHOW.WELCOME";
- public static final String SHOW_LEFT_PANE = "SHOW.PANE.LEFT";
- public static final String SHOW_BOTTOM_PANE = "SHOW.PANE.BOTTOM";
- public static final String LOOK_AND_FEEL = "LOOK.AND.FEEL";
- public static final String DEBUG_LEVEL = "DEBUG.LEVEL";
- public static final String BROWSER_PATH = "BROWSER.PATH";
- public static final String INTEGRATION_PORT = "INTEGRATION.PORT";
- public static final String OPEN_FROM_BASE = "OPEN.FROM.BASE";
- public static final String SAVE_TO_BASE = "SAVE.TO.BASE";
- public static final String APP_FONT = "APP.FONT";
- public static final String DOC_FONT = "DOC.FONT";
- public static final String SRC_FONT = "SRC.FONT";
- public static final String LEFT_MARGIN = "MARGIN.LEFT";
- public static final String RIGHT_MARGIN = "MARGIN.RIGHT";
- public static final String TOP_MARGIN = "MARGIN.TOP";
- public static final String BOTTOM_MARGIN = "MARGIN.BOTTOM";
- public static final String PRINT_PREF_ORIENTATION = "PRINT.PREF.ORIENTATION";
- public static final String PRINT_PREF_WIDTH = "PRINT.PREF.WIDTH";
- public static final String PRINT_PREF_HEIGHT = "PRINT.PREF.HEIGHT";
- public static final String PRINT_PREF_IMAGEABLE_X = "PRINT.PREF.IMAGEABLE.X";
- public static final String PRINT_PREF_IMAGEABLE_Y = "PRINT.PREF.IMAGEABLE.Y";
- public static final String PRINT_PREF_IMAGEABLE_WIDTH = "PRINT.PREF.IMAGEABLE.WIDTH";
- public static final String PRINT_PREF_IMAGEABLE_HEIGHT = "PRINT.PREF.IMAGEABLE.HEIGHT";
- public static final String NUMS = "NUMS";
- public static final String TRUE = "TRUE";
- public static final String FALSE = "FALSE";
- public static final String ASK = "ASK";
- private static final int[] LAUNCH_CODES = new int[]{17054, 17296, 15217, 18688, 13450, 13015, 14645, 13151, 14322, 10118, 16682, 19513, 10317, 19393, 19578, 11150, 16933, 17466, 14093, 13906, 12261, 13193, 14278, 13754, 14009, 16575, 10757, 16949, 19035, 10161, 16504, 12686, 15379, 12956, 15133, 18256, 16795, 16826, 11671, 16703, 19780, 15404, 15842, 16975, 13106, 15497, 17849, 16589, 19852, 10993, 16657, 16781, 11936, 19265, 10768, 10163, 17143, 10081, 11509, 10882, 18661, 17003, 18810, 17272, 17108, 11304, 19485, 17017, 15065, 18363, 18015, 14798, 14108, 16581, 19828, 12457, 14336, 18780, 17080, 11651, 16407, 16114, 16938, 19004, 16067, 14471, 12358, 13772, 11180, 13383, 15370, 15370};
- public static final String SOX_SCHEMA_PATH = "SOX.SCHEMA.PATH";
- static File file;
- public static final String DEFAULT_FILE_TYPE = "DEFAULT.FILE.TYPE";
-
- public void readInitial(File var1) {
- FileInputStream var2 = null;
-
- try {
- if (file == null) {
- file = var1;
- }
-
- var2 = new FileInputStream(file);
- ((Properties)this).load(var2);
- var2.close();
- } catch (FileNotFoundException var5) {
- this.initialize();
- } catch (IOException var6) {
- DialogFactory.showException((Component)null, 121, var6);
- this.initialize();
- if (var2 != null) {
- try {
- var2.close();
- } catch (IOException var4) {
- }
- }
- }
-
- }
-
- private void initialize() {
- ((Hashtable)this).put("RECENT.1", "");
- ((Hashtable)this).put("RECENT.2", "");
- ((Hashtable)this).put("RECENT.3", "");
- ((Hashtable)this).put("RECENT.4", "");
- ((Hashtable)this).put("RECENT.5", "");
- ((Hashtable)this).put("ESB", "");
- ((Hashtable)this).put("KKB", "");
- ((Hashtable)this).put("CAB", "");
- ((Hashtable)this).put("SHOW.WELCOME", "TRUE");
- ((Hashtable)this).put("ONLINE.HELP", "TRUE");
-
- try {
- this.save();
- } catch (IOException var2) {
- ((Throwable)var2).printStackTrace();
- DialogFactory.showException((Component)null, 108, var2);
- }
-
- }
-
- public void save() throws IOException {
- FileOutputStream var1 = null;
-
- try {
- var1 = new FileOutputStream(file);
- ((Properties)this).save(var1, UI.getString("splash.title") + " preferences");
- } finally {
- if (var1 != null) {
- ((OutputStream)var1).close();
- }
-
- }
-
- }
-
- public String getLookAndFeel() {
- String var1 = ((Properties)this).getProperty("LOOK.AND.FEEL");
- if (var1 == null) {
- String var2 = System.getProperty("os.name");
- return var2.startsWith("Mac") ? "it.unitn.ing.swing.plaf.macos.MacOSLookAndFeel" : "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
- } else {
- return var1;
- }
- }
-
- public void updateLookAndFeel(String var1) {
- ((Hashtable)this).put("LOOK.AND.FEEL", var1);
- }
-
- public Font getAppFont() {
- String var1 = (String)((Hashtable)this).get("APP.FONT");
- return var1 == null ? new Font("SansSerif", 0, 11) : Font.decode(var1);
- }
-
- public void updateAppFont(Font var1) {
- ((Hashtable)this).put("APP.FONT", var1.getName() + "-" + var1.getSize());
- }
-
- public Font getDocFont() {
- String var1 = (String)((Hashtable)this).get("DOC.FONT");
- return var1 == null ? null : Font.decode(var1);
- }
-
- public void updateDocFont(Font var1) {
- ((Hashtable)this).put("DOC.FONT", var1.getName() + "-" + var1.getSize());
- }
-
- public void updateDocFont(int var1) {
- if (var1 == -1) {
- ((Hashtable)this).remove("DOC.FONT");
- } else {
- Font var2 = this.getDocFont();
- String var3 = var2 == null ? "SansSerif" : var2.getName();
- ((Hashtable)this).put("DOC.FONT", var3 + "-" + var1);
- }
-
- }
-
- public void updateDocFont(String var1, int var2) {
- if (var1 == null) {
- var1 = "SansSerif";
- }
-
- if (var2 == -1) {
- ((Hashtable)this).put("DOC.FONT", var1);
- } else {
- ((Hashtable)this).put("DOC.FONT", var1 + "-" + var2);
- }
-
- }
-
- public void updateSrcFont(String var1, int var2) {
- if (var1 == null) {
- var1 = "SansSerif";
- }
-
- if (var2 == -1) {
- ((Hashtable)this).put("SRC.FONT", var1);
- } else {
- ((Hashtable)this).put("SRC.FONT", var1 + "-" + var2);
- }
-
- }
-
- public Font getSrcFont() {
- String var1 = (String)((Hashtable)this).get("SRC.FONT");
- return var1 == null ? null : Font.decode(var1);
- }
-
- public void updateSrcFont(Font var1) {
- ((Hashtable)this).put("SRC.FONT", var1.getName() + "-" + var1.getSize());
- }
-
- public int getLaunchesLeft() {
- String var1 = ((Properties)this).getProperty("EGB");
- if (var1 == null) {
- return 0;
- } else {
- int var2 = Integer.valueOf(var1);
-
- for(int var3 = 0; var3 < LAUNCH_CODES.length; ++var3) {
- if (LAUNCH_CODES[var3] == var2) {
- return var3;
- }
- }
-
- return 0;
- }
- }
-
- public void updateLaunchesLeft(int var1) {
- Debug.assert(var1 >= 0 && var1 < LAUNCH_CODES.length, "invalid newLeft: " + var1);
- ((Hashtable)this).put("EGB", (new Integer(LAUNCH_CODES[var1])).toString());
-
- try {
- this.save();
- } catch (Exception var2) {
- }
-
- }
-
- public void initTrialLaunchesLeft(int var1) {
- ((Hashtable)this).put("EGB", (new Integer(LAUNCH_CODES[var1])).toString());
- }
-
- public boolean getOnlineHelp() {
- String var1 = ((Properties)this).getProperty("ONLINE.HELP");
- return var1 == null ? false : Boolean.valueOf(var1);
- }
-
- public void updateOnlineHelp(boolean var1) {
- ((Hashtable)this).put("ONLINE.HELP", (new Boolean(var1)).toString());
- }
-
- public boolean getExternalHelpBrowser() {
- String var1 = ((Properties)this).getProperty("EXTERNAL.HELP.BROWSER");
- return var1 == null ? false : Boolean.valueOf(var1);
- }
-
- public void updateExternalHelpBrowser(boolean var1) {
- ((Hashtable)this).put("EXTERNAL.HELP.BROWSER", (new Boolean(var1)).toString());
- }
-
- public boolean getShowWelcome() {
- String var1 = ((Properties)this).getProperty("SHOW.WELCOME");
- return var1 == null ? true : Boolean.valueOf(var1);
- }
-
- public void updateShowWelcome(boolean var1) {
- ((Hashtable)this).put("SHOW.WELCOME", (new Boolean(var1)).toString());
- }
-
- public boolean getShowLeftPane() {
- String var1 = ((Properties)this).getProperty("SHOW.PANE.LEFT");
- return var1 == null ? false : Boolean.valueOf(var1);
- }
-
- public void updateShowLeftPane(boolean var1) {
- ((Hashtable)this).put("SHOW.PANE.LEFT", (new Boolean(var1)).toString());
- }
-
- public boolean getShowBottomPane() {
- String var1 = ((Properties)this).getProperty("SHOW.PANE.BOTTOM");
- return var1 == null ? false : Boolean.valueOf(var1);
- }
-
- public void updateShowBottomPane(boolean var1) {
- ((Hashtable)this).put("SHOW.PANE.BOTTOM", (new Boolean(var1)).toString());
- }
-
- public String[] getMargins() {
- String[] var1 = new String[4];
- String var2 = ((Properties)this).getProperty("MARGIN.LEFT");
- if (var2 == null) {
- var1[2] = "60";
- } else {
- var1[2] = var2;
- }
-
- String var3 = ((Properties)this).getProperty("MARGIN.RIGHT");
- if (var3 == null) {
- var1[3] = "60";
- } else {
- var1[3] = var3;
- }
-
- String var4 = ((Properties)this).getProperty("MARGIN.TOP");
- if (var4 == null) {
- var1[0] = "60";
- } else {
- var1[0] = var4;
- }
-
- String var5 = ((Properties)this).getProperty("MARGIN.BOTTOM");
- if (var5 == null) {
- var1[1] = "60";
- } else {
- var1[1] = var5;
- }
-
- return var1;
- }
-
- public PrintPreferences getPrintPreferences() {
- PrintPreferences var1 = new PrintPreferences();
- String var2 = ((Properties)this).getProperty("PRINT.PREF.ORIENTATION");
- String var3 = ((Properties)this).getProperty("PRINT.PREF.WIDTH");
- String var4 = ((Properties)this).getProperty("PRINT.PREF.HEIGHT");
- String var5 = ((Properties)this).getProperty("PRINT.PREF.IMAGEABLE.X");
- String var6 = ((Properties)this).getProperty("PRINT.PREF.IMAGEABLE.Y");
- String var7 = ((Properties)this).getProperty("PRINT.PREF.IMAGEABLE.WIDTH");
- String var8 = ((Properties)this).getProperty("PRINT.PREF.IMAGEABLE.HEIGHT");
- if (var2 == null) {
- var2 = Integer.toString(1);
- }
-
- if (var3 == null) {
- var3 = Double.toString((double)612.0F);
- }
-
- if (var4 == null) {
- var4 = Double.toString((double)792.0F);
- }
-
- if (var5 == null) {
- var5 = Double.toString((double)72.0F);
- }
-
- if (var6 == null) {
- var6 = Double.toString((double)72.0F);
- }
-
- if (var7 == null) {
- var7 = Double.toString((double)468.0F);
- }
-
- if (var8 == null) {
- var8 = Double.toString((double)648.0F);
- }
-
- var1.setOrientation(Integer.parseInt(var2));
- var1.setWidth(Double.valueOf(var3));
- var1.setHeight(Double.valueOf(var4));
- var1.setImageableX(Double.valueOf(var5));
- var1.setImageableY(Double.valueOf(var6));
- var1.setImageableWidth(Double.valueOf(var7));
- var1.setImageableHeight(Double.valueOf(var8));
- return var1;
- }
-
- public int getDebugLevel() {
- String var1 = (String)((Hashtable)this).get("DEBUG.LEVEL");
- if (var1 == null) {
- return 0;
- } else {
- int var2 = Integer.valueOf(var1);
- return var2;
- }
- }
-
- public String getBrowserPath() {
- String var1 = (String)((Hashtable)this).get("BROWSER.PATH");
- return var1;
- }
-
- public String getOpenFromBase() {
- String var1 = (String)((Hashtable)this).get("OPEN.FROM.BASE");
- return var1;
- }
-
- public void updateOpenFromBase(String var1) {
- ((Hashtable)this).put("OPEN.FROM.BASE", var1);
- }
-
- public String getSaveToBase() {
- String var1 = (String)((Hashtable)this).get("SAVE.TO.BASE");
- return var1;
- }
-
- public void updateSaveToBase(String var1) {
- ((Hashtable)this).put("SAVE.TO.BASE", var1);
- }
-
- public void updateDebugLevel(int var1) {
- ((Hashtable)this).put("DEBUG.LEVEL", (new Integer(var1)).toString());
- }
-
- public void updateBrowserPath(String var1) {
- if (var1 != null && var1.length() != 0) {
- ((Hashtable)this).put("BROWSER.PATH", var1);
- } else {
- ((Hashtable)this).remove("BROWSER.PATH");
- }
-
- }
-
- public void updateMargins(String[] var1) {
- ((Hashtable)this).put("MARGIN.LEFT", var1[2]);
- ((Hashtable)this).put("MARGIN.RIGHT", var1[3]);
- ((Hashtable)this).put("MARGIN.TOP", var1[0]);
- ((Hashtable)this).put("MARGIN.BOTTOM", var1[1]);
- }
-
- public void updatePrintPreferences(PrintPreferences var1) {
- ((Hashtable)this).put("PRINT.PREF.ORIENTATION", Integer.toString(var1.getOrientation()));
- ((Hashtable)this).put("PRINT.PREF.WIDTH", Double.toString(var1.getWidth()));
- ((Hashtable)this).put("PRINT.PREF.HEIGHT", Double.toString(var1.getHeight()));
- ((Hashtable)this).put("PRINT.PREF.IMAGEABLE.X", Double.toString(var1.getImageableX()));
- ((Hashtable)this).put("PRINT.PREF.IMAGEABLE.Y", Double.toString(var1.getImageableY()));
- ((Hashtable)this).put("PRINT.PREF.IMAGEABLE.WIDTH", Double.toString(var1.getImageableWidth()));
- ((Hashtable)this).put("PRINT.PREF.IMAGEABLE.HEIGHT", Double.toString(var1.getImageableHeight()));
- }
-
- public int getToolbarView() {
- String var1 = ((Properties)this).getProperty("TOOLBAR.VIEW");
- return var1 == null ? 1 : Integer.parseInt(var1);
- }
-
- public void updateToolBarView(int var1) {
- ((Hashtable)this).put("TOOLBAR.VIEW", (new Integer(var1)).toString());
- }
-
- public void removeFromRecent(URI var1) {
- String var2 = var1.getFullName();
-
- for(int var3 = 1; var3 <= 5; ++var3) {
- String var4 = ((Properties)this).getProperty("RECENT." + var3);
- if (var4 != null && var4.equals(var2)) {
- ((Hashtable)this).remove("RECENT." + var3);
- break;
- }
- }
-
- Vector var9 = new Vector();
-
- for(int var5 = 1; var5 <= 5; ++var5) {
- String var6 = ((Properties)this).getProperty("RECENT." + var5);
- if (var6 != null) {
- var9.addElement(var6);
- ((Hashtable)this).remove("RECENT." + var5);
- }
- }
-
- int var10 = 1;
- Enumeration var7 = var9.elements();
-
- while(var7.hasMoreElements()) {
- ((Hashtable)this).put("RECENT." + var10++, (String)var7.nextElement());
- }
-
- try {
- this.save();
- } catch (Exception var8) {
- }
-
- }
-
- public void updateRecent(String var1, URI var2) {
- String var4 = var2.getFullName();
- if (var4 != null && !var4.equals("")) {
- int var3;
- for(var3 = 5; var3 > 0; --var3) {
- String var5 = ((Properties)this).getProperty(var1 + var3);
- if (var5 != null && var5.equals(var4)) {
- return;
- }
- }
-
- if (var3 == 0) {
- for(int var9 = 5; var9 > 1; --var9) {
- String var6 = ((Properties)this).getProperty(var1 + (var9 - 1));
- if (var6 != null) {
- ((Hashtable)this).put(var1 + var9, var6);
- }
- }
-
- var3 = 1;
- }
-
- ((Hashtable)this).put(var1 + 1, var4);
-
- try {
- this.save();
- } catch (Exception var7) {
- }
-
- }
- }
-
- public void updateRecent(URI var1) {
- this.updateRecent("RECENT.", var1);
- }
-
- public String getDefaultFileType() {
- String var1 = (String)((Hashtable)this).get("DEFAULT.FILE.TYPE");
- if (var1 == null) {
- var1 = UI.getString("com.extensibility.app.defaultfiletype");
- }
-
- return var1;
- }
-
- public void updateDefaultFileType(String var1) {
- ((Hashtable)this).put("DEFAULT.FILE.TYPE", var1);
- }
-
- public String getSchemaPath() {
- String var1 = (String)((Hashtable)this).get("SOX.SCHEMA.PATH");
- return var1;
- }
-
- public void updateSchemaPath(String var1) {
- ((Hashtable)this).put("SOX.SCHEMA.PATH", var1);
- }
-
- public void setGeneralPreference(String var1, String var2) {
- ((Hashtable)this).put(var1, var2);
- }
- }
-